package com.demo15;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class OutputStreamDemo2 {
    public static void main(String[] args) {
        //写入文件的操作展示
        //开启文件流操作展示
        FileOutputStream fos = null;
        try {
             fos = new FileOutputStream("idea_demo\\java\\javaSE\\java.txt",true);
            for (int i=0;i<10;i++){
                fos.write(("hello"+i).getBytes());
                fos.write("\r\n".getBytes());
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //判断是否为空
            if(fos !=null){
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

        }
    }
}
